package proxy;

import net.sf.cglib.proxy.Enhancer;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/11/25  18:44
 */
public class IntermediaryCglibProxyFactory {
    private static IntermediaryMethodInterceptor callback=new IntermediaryMethodInterceptor();

    public static <T> T create(Class<T> taeget){
        Enhancer enhancer = new Enhancer();
        //为重写的方法指定回调的MethodInter
        enhancer.setCallback(callback);
        enhancer.setSuperclass(taeget);
        return (T)enhancer.create();
    }
}
